package com.jxzn.locust.dao;

import java.util.List;
import java.util.Set;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.jxzn.locust.model.SysResource;

@Repository
public interface ResourceRepository extends AbstractRepository<SysResource> {

    @Query("update SysResource set updateTime=now() where uuid in :uuidSet")
    @Modifying
    void updateByUuid(@Param("uuidSet") Set<String> uuidSet);

    @Query(nativeQuery = true, value = "select s.* from sys_role_resource r left join sys_resource s on r.resource_uuid=s.uuid where r.role_id=:roleId")
    List<SysResource> findByRoleId(@Param("roleId") int roleId);
}
